package com.lanlengran.imagemake;

import android.content.Context;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LinearLayout linearLayout=new LinearLayout(this);
        ImageView imageView=new ImageView(this);
        ImageView imageView2=new ImageView(this);
        linearLayout.addView(imageView);
        linearLayout.addView(imageView2);
        ViewGroup.LayoutParams layoutParams = imageView.getLayoutParams();
        WindowManager wm= (WindowManager) getSystemService(Context.WINDOW_SERVICE);
        layoutParams.height= (int) (wm.getDefaultDisplay().getHeight()*0.4);
        layoutParams.width=wm.getDefaultDisplay().getWidth();
        imageView.setLayoutParams(layoutParams);
        imageView2.setLayoutParams(layoutParams);
        linearLayout.setOrientation(LinearLayout.VERTICAL);
        Bitmap bitmap= BitmapUtils.bitmapCompress("./mnt/shared/Image/test.jpg",200);
        imageView.setImageBitmap(bitmap);
  //      imageView2.setImageBitmap(bitmap);
        Bitmap newBm=ImageUtils.bitmap2BlackImage(bitmap);
        imageView2.setImageBitmap(newBm);
        setContentView(linearLayout);
        ImageUtils.bitmapToTxt(newBm,"./mnt/shared/Image/test.nc");
    }
}
